package com.imcode.mapdemo;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class TreeMapDemo {

    public static void main(String[] args) {
        /**
        Map<String, String> map = new TreeMap<>();
        map.put("2018001001", null);
        map.put("2017002001", null);
        map.put("2019102020", null);
        map.put("2019010101", null);
        map.put("2019102920", null);

        Set<String> set = map.keySet();
        for (String key : set) {
            System.out.println(key);
        }**/


        //Map<Order,String> map1 = new TreeMap<>();
        Map<Order,String> map1 = new TreeMap<>(new Comparator<Order>() {
            @Override
            public int compare(Order o1, Order o2) {
                return -o1.getOrderNumber().compareTo(o2.getOrderNumber());
            }
        });
        map1.put(new Order("2018001001"),null);
        map1.put(new Order("2017002001"),null);
        map1.put(new Order("2019102020"),null);
        map1.put(new Order("2019010101"),null);
        map1.put(new Order("2019102920"),null);

        Set<Order> set1 = map1.keySet();
        for (Order order : set1){
            System.out.println(order.getOrderNumber());
        }
    }
}
